package com.eksframework.commons.core.base;

import javax.annotation.Nullable;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Map;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;

/**
 * 校验类
 *
 * @author chenfenghai
 * @date 2019-12-11 15:46
 * @blame Android Team
 */
public class EksCheck {

    /**
     * Constructor.
     */
    EksCheck() {
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是null值
     *
     * <pre>
     * EksCheck.isNull(null)      = true
     * EksCheck.isNull("")        = false
     * EksCheck.isNull(" ")       = false
     * EksCheck.isNull("bob")     = false
     * EksCheck.isNull("  bob  ") = false
     * </pre>
     *
     * @param <T>    the object type
     * @param object the object to check
     * @return boolean the validated result true or false
     */
    public static <T> boolean isNull(@Nullable final T object) {
        return object == null;
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 不是null值
     *
     * <pre>
     * EksCheck.notNull(null)      = false
     * EksCheck.notNull("")        = true
     * EksCheck.notNull(" ")       = true
     * EksCheck.notNull("bob")     = true
     * EksCheck.notNull("  bob  ") = true
     * </pre>
     *
     * @param <T>    the object type
     * @param object the object to check
     * @return boolean the validated result true or false
     */
    public static <T> boolean notNull(@Nullable final T object) {
        return object != null;
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否相等
     *
     * @param number the number of check
     * @param norm   the BigDecimal norm
     * @return boolean the validated result true or false
     */
    public static boolean isEqual(@Nullable final BigDecimal number, BigDecimal norm) {
        if (number == null && norm == null) {
            return true;
        }
        if (number == null || norm == null) {
            return false;
        }
        return number.compareTo(norm) == 0;
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否不相等
     *
     * @param number the number of check
     * @param norm   the BigDecimal norm
     * @return boolean the validated result true or false
     */
    public static boolean notEqual(@Nullable final BigDecimal number, BigDecimal norm) {
        if (number == null && norm == null) {
            return false;
        }
        if (number == null || norm == null) {
            return true;
        }
        return number.compareTo(norm) != 0;
    }
    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否大于
     *
     * @param number the number of check
     * @param norm   the BigDecimal norm
     * @return boolean the validated result true or false
     */
    public static boolean isGreaterThan(@Nullable final BigDecimal number, BigDecimal norm) {
        return number != null && norm != null && number.compareTo(norm) > 0;
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否大于等于
     *
     * @param number the number of check
     * @param norm   the BigDecimal norm
     * @return boolean the validated result true or false
     */
    public static boolean isGreaterThanEqual(@Nullable final BigDecimal number, BigDecimal norm) {
        return isEqual(number, norm) || isGreaterThan(number, norm);
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否小于
     *
     * @param number the number of check
     * @param norm   the BigDecimal norm
     * @return boolean the validated result true or false
     */
    public static boolean isLessThan(@Nullable final BigDecimal number, BigDecimal norm) {
        return number != null && norm != null && number.compareTo(norm) < 0;
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否小于等于
     *
     * @param number the number of check
     * @param norm   the BigDecimal norm
     * @return boolean the validated result true or false
     */
    public static boolean isLessThanEqual(@Nullable final BigDecimal number, BigDecimal norm) {
        return isEqual(number, norm) || isLessThan(number, norm);
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否等于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isEqualZero(@Nullable final BigDecimal number) {
        return isEqual(number, BigDecimal.ZERO);
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否不等于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean notEqualZero(@Nullable final BigDecimal number) {
        return notEqual(number, BigDecimal.ZERO);
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否大于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isGreaterThanZero(@Nullable final BigDecimal number) {
        return isGreaterThan(number, BigDecimal.ZERO);
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否大于等于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isGreaterThanEqualZero(@Nullable final BigDecimal number) {
        return isGreaterThanEqual(number, BigDecimal.ZERO);
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否小于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isLessThanZero(@Nullable final BigDecimal number) {
        return isLessThan(number, BigDecimal.ZERO);
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否小于等于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isLessThanEqualZero(@Nullable final BigDecimal number) {
        return isLessThanEqual(number, BigDecimal.ZERO);
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否等于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isEqualOne(@Nullable final BigDecimal number) {
        return isEqual(number, BigDecimal.ONE);
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否不等于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean notEqualOne(@Nullable final BigDecimal number) {
        return notEqual(number, BigDecimal.ONE);
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否大于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isGreaterThanOne(@Nullable final BigDecimal number) {
        return isGreaterThan(number, BigDecimal.ONE);
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否大于等于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isGreaterThanEqualOne(@Nullable final BigDecimal number) {
        return isGreaterThanEqual(number, BigDecimal.ONE);
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否小于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isLessThanOne(@Nullable final BigDecimal number) {
        return isLessThan(number, BigDecimal.ONE);
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否小于等于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isLessThanEqualOne(@Nullable final BigDecimal number) {
        return isLessThanEqual(number, BigDecimal.ONE);
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否等于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isEqualZero(final int number) {
        return isEqualZero(new BigDecimal(number));
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否不等于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean notEqualZero(final int number) {
        return notEqualZero(new BigDecimal(number));
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否大于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isGreaterThanZero(final int number) {
        return isGreaterThanZero(new BigDecimal(number));
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否大于等于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isGreaterThanEqualZero(final int number) {
        return isGreaterThanEqualZero(new BigDecimal(number));
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否小于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isLessThanZero(final int number) {
        return isLessThanZero(new BigDecimal(number));
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否小于等于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isLessThanEqualZero(final int number) {
        return isLessThanEqualZero(new BigDecimal(number));
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否等于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isEqualOne(final int number) {
        return isEqualOne(new BigDecimal(number));
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否不等于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean notEqualOne(final int number) {
        return notEqualOne(new BigDecimal(number));
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否大于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isGreaterThanOne(final int number) {
        return isGreaterThanOne(new BigDecimal(number));
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否大于等于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isGreaterThanEqualOne(final int number) {
        return isGreaterThanEqualOne(new BigDecimal(number));
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否小于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isLessThanOne(final int number) {
        return isLessThanOne(new BigDecimal(number));
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否小于等于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isLessThanEqualOne(final int number) {
        return isLessThanEqualOne(new BigDecimal(number));
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否等于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isEqualZero(@Nullable final Integer number) {
        return number != null && isEqualZero(number.intValue());
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否不等于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean notEqualZero(@Nullable final Integer number) {
        return number == null || notEqualZero(number.intValue());
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否大于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isGreaterThanZero(@Nullable final Integer number) {
        return number != null && isGreaterThanZero(number.intValue());
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否大于等于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isGreaterThanEqualZero(@Nullable final Integer number) {
        return number != null && isGreaterThanEqualZero(number.intValue());
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否小于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isLessThanZero(@Nullable final Integer number) {
        return number != null && isLessThanZero(number.intValue());
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否小于等于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isLessThanEqualZero(@Nullable final Integer number) {
        return number != null && isLessThanEqualZero(number.intValue());
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否等于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isEqualOne(@Nullable final Integer number) {
        return number != null && isEqualOne(number.intValue());
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否不等于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean notEqualOne(@Nullable final Integer number) {
        return number == null || notEqualOne(number.intValue());
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否大于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isGreaterThanOne(@Nullable final Integer number) {
        return number != null && isGreaterThanOne(number.intValue());
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否大于等于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isGreaterThanEqualOne(@Nullable final Integer number) {
        return number != null && isGreaterThanEqualOne(number.intValue());
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否小于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isLessThanOne(@Nullable final Integer number) {
        return number != null && isLessThanOne(number.intValue());
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否小于等于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isLessThanEqualOne(@Nullable final Integer number) {
        return number != null && isLessThanEqualOne(number.intValue());
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否等于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isEqualZero(final long number) {
        return isEqualZero(new BigDecimal(number));
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否不等于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean notEqualZero(final long number) {
        return notEqualZero(new BigDecimal(number));
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否大于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isGreaterThanZero(final long number) {
        return isGreaterThanZero(new BigDecimal(number));
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否大于等于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isGreaterThanEqualZero(final long number) {
        return isGreaterThanEqualZero(new BigDecimal(number));
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否小于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isLessThanZero(final long number) {
        return isLessThanZero(new BigDecimal(number));
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否小于等于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isLessThanEqualZero(final long number) {
        return isLessThanEqualZero(new BigDecimal(number));
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否等于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isEqualOne(final long number) {
        return isEqualOne(new BigDecimal(number));
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否不等于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean notEqualOne(final long number) {
        return notEqualOne(new BigDecimal(number));
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否大于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isGreaterThanOne(final long number) {
        return isGreaterThanOne(new BigDecimal(number));
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否大于等于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isGreaterThanEqualOne(final long number) {
        return isGreaterThanEqualOne(new BigDecimal(number));
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否小于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isLessThanOne(final long number) {
        return isLessThanOne(new BigDecimal(number));
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否小于等于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isLessThanEqualOne(final long number) {
        return isLessThanEqualOne(new BigDecimal(number));
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否等于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isEqualZero(@Nullable final Long number) {
        return number != null && isEqualZero(number.longValue());
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否不等于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean notEqualZero(@Nullable final Long number) {
        return number == null || notEqualZero(number.longValue());
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否大于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isGreaterThanZero(@Nullable final Long number) {
        return number != null && isGreaterThanZero(number.longValue());
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否大于等于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isGreaterThanEqualZero(@Nullable final Long number) {
        return number != null && isGreaterThanEqualZero(number.longValue());
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否小于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isLessThanZero(@Nullable final Long number) {
        return number != null && isLessThanZero(number.longValue());
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否小于等于0
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isLessThanEqualZero(@Nullable final Long number) {
        return number != null && isLessThanEqualZero(number.longValue());
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否等于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isEqualOne(@Nullable final Long number) {
        return number != null && isEqualOne(number.longValue());
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否不等于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean notEqualOne(@Nullable final Long number) {
        return number == null || notEqualOne(number.longValue());
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否大于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isGreaterThanOne(@Nullable final Long number) {
        return number != null && isGreaterThanOne(number.longValue());
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否大于等于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isGreaterThanEqualOne(@Nullable final Long number) {
        return number != null && isGreaterThanEqualOne(number.longValue());
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否小于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isLessThanOne(@Nullable final Long number) {
        return number != null && isLessThanOne(number.longValue());
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是否小于等于1
     *
     * @param number the number of check
     * @return boolean the validated result true or false
     */
    public static boolean isLessThanEqualOne(@Nullable final Long number) {
        return number != null && isLessThanEqualOne(number.longValue());
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是空值
     *
     * <pre>
     * EksCheck.isEmpty(null)      = true
     * EksCheck.isEmpty("")        = true
     * EksCheck.isEmpty(" ")       = false
     * EksCheck.isEmpty("bob")     = false
     * EksCheck.isEmpty("  bob  ") = false
     * </pre>
     *
     * @param <T>    the object type
     * @param object the object to check
     * @return boolean the validated result true or false
     */
    public static <T> boolean isEmpty(@Nullable final T object) {
        return object == null || String.valueOf(object).isEmpty();
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是空值
     *
     * @param <T>   the object type
     * @param chars the object to check
     * @return boolean the validated result true or false
     */
    public static <T extends CharSequence> boolean isEmpty(@Nullable final T chars) {
        return chars == null || chars.length() == 0;
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是空值
     *
     * @param <T>   the object type
     * @param array the object to check
     * @return boolean the validated result true or false
     */
    public static <T> boolean isEmpty(@Nullable final T[] array) {
        return array == null || array.length == 0;
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是空值
     *
     * @param <T>        the object type
     * @param collection the object to check
     * @return boolean the validated result true or false
     */
    public static <T extends Collection<?>> boolean isEmpty(@Nullable final T collection) {
        return collection == null || collection.isEmpty();
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是空值
     *
     * @param <T> the object type
     * @param map the object to check
     * @return boolean the validated result true or false
     */
    public static <T extends Map<?, ?>> boolean isEmpty(@Nullable final T map) {
        return map == null || map.isEmpty();
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 不是空值
     *
     * <pre>
     * EksCheck.isEmpty(null)      = false
     * EksCheck.isEmpty("")        = false
     * EksCheck.isEmpty(" ")       = true
     * EksCheck.isEmpty("bob")     = true
     * EksCheck.isEmpty("  bob  ") = true
     * </pre>
     *
     * @param <T>    the object type
     * @param object the object to check
     * @return boolean the validated result true or false
     */
    public static <T> boolean notEmpty(@Nullable final T object) {
        return !isEmpty(object);
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 不是空值
     *
     * @param <T>   the object type
     * @param chars the object to check
     * @return boolean the validated result true or false
     */
    public static <T extends CharSequence> boolean notEmpty(@Nullable final T chars) {
        return !isEmpty(chars);
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 不是空值
     *
     * @param <T>   the object type
     * @param array the object to check
     * @return boolean the validated result true or false
     */
    public static <T> boolean notEmpty(@Nullable final T[] array) {
        return !isEmpty(array);
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 不是空值
     *
     * @param <T>        the object type
     * @param collection the object to check
     * @return boolean the validated result true or false
     */
    public static <T extends Collection<?>> boolean notEmpty(@Nullable final T collection) {
        return !isEmpty(collection);
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 不是空值
     *
     * @param <T> the object type
     * @param map the object to check
     * @return boolean the validated result true or false
     */
    public static <T extends Map<?, ?>> boolean notEmpty(@Nullable final T map) {
        return !isEmpty(map);
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是空值
     *
     * <pre>
     * EksCheck.isBlank(null)      = true
     * EksCheck.isBlank("")        = true
     * EksCheck.isBlank(" ")       = true
     * EksCheck.isBlank("bob")     = false
     * EksCheck.isBlank("  bob  ") = false
     * </pre>
     *
     * @param <T>   the object type
     * @param chars the object to check
     * @return boolean the validated result true or false
     */
    public static <T extends CharSequence> boolean isBlank(@Nullable final T chars) {
        int strLen;
        if (chars == null || (strLen = chars.length()) == 0) {
            return true;
        }
        for (int i = 0; i < strLen; i++) {
            if (!Character.isWhitespace(chars.charAt(i))) {
                return false;
            }
        }
        return true;
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 是空值
     *
     * <pre>
     * EksCheck.isBlank(null)      = true
     * EksCheck.isBlank("")        = true
     * EksCheck.isBlank(" ")       = true
     * EksCheck.isBlank("bob")     = false
     * EksCheck.isBlank("  bob  ") = false
     * </pre>
     *
     * @param <T>    the object type
     * @param object the object to check
     * @return boolean the validated result true or false
     */
    public static <T> boolean isBlank(@Nullable final T object) {
        return object == null || isBlank(object.toString());
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 不是空值
     *
     * <pre>
     * EksCheck.notBlank(null)      = false
     * EksCheck.notBlank("")        = false
     * EksCheck.notBlank(" ")       = false
     * EksCheck.notBlank("bob")     = true
     * EksCheck.notBlank("  bob  ") = true
     * </pre>
     *
     * @param <T>   the object type
     * @param chars the object to check
     * @return boolean the validated result true or false
     */
    public static <T extends CharSequence> boolean notBlank(@Nullable final T chars) {
        return !isBlank(chars);
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 不是空值
     *
     * <pre>
     * EksCheck.notBlank(null)      = false
     * EksCheck.notBlank("")        = false
     * EksCheck.notBlank(" ")       = false
     * EksCheck.notBlank("bob")     = true
     * EksCheck.notBlank("  bob  ") = true
     * </pre>
     *
     * @param <T>    the object type
     * @param object the object to check
     * @return boolean the validated result true or false
     */
    public static <T> boolean notBlank(@Nullable final T object) {
        return !isBlank(object);
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 判断字符串是否日期格式：yyyy-MM-dd
     *
     * <pre>
     * EksCheck.isDate(null)                   = false
     * EksCheck.isDate("")                     = false
     * EksCheck.isDate("2019/10/18")           = false
     * EksCheck.isDate("2019-10-18 12:12:12")  = false
     * EksCheck.isDate("2019-10-18")           = true
     * </pre>
     *
     * @param <T>   the object type
     * @param chars the chars to check
     * @return boolean the validated result true or false
     * @see EksDate#isDate(CharSequence)
     */
    public static <T extends CharSequence> boolean isDate(@Nullable final T chars) {
        return EksDate.isDate(chars);
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 判断字符串是否日期格式：yyyy-MM-dd
     *
     * <pre>
     * EksCheck.isDate(null)                   = false
     * EksCheck.isDate("")                     = false
     * EksCheck.isDate("2019/10/18")           = false
     * EksCheck.isDate("2019-10-18 12:12:12")  = false
     * EksCheck.isDate("2019-10-18")           = true
     * </pre>
     *
     * @param <T>    the object type
     * @param object the object to check
     * @return boolean the validated result true or false
     * @see EksDate#isDate(CharSequence)
     */
    public static <T> boolean isDate(@Nullable final T object) {
        return object != null && EksDate.isDate(String.valueOf(object));
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 判断字符串是否日期时间格式：yyyy-MM-dd HH:mm:ss
     *
     * <pre>
     * EksCheck.isDateTime(null)                   = false
     * EksCheck.isDateTime("")                     = false
     * EksCheck.isDateTime("2019/10/18")           = false
     * EksCheck.isDateTime("2019-10-18 12:12:12")  = true
     * EksCheck.isDateTime("2019-10-18")           = false
     * </pre>
     *
     * @param <T>   the object type
     * @param chars the object to check
     * @return boolean the validated result true or false
     * @see EksDate#isDateTime(CharSequence)
     */
    public static <T extends CharSequence> boolean isDateTime(@Nullable final T chars) {
        return EksDate.isDateTime(chars);
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 判断字符串是否日期时间格式：yyyy-MM-dd HH:mm:ss
     *
     * <pre>
     * EksCheck.isDateTime(null)                   = false
     * EksCheck.isDateTime("")                     = false
     * EksCheck.isDateTime("2019/10/18")           = false
     * EksCheck.isDateTime("2019-10-18 12:12:12")  = true
     * EksCheck.isDateTime("2019-10-18")           = false
     * </pre>
     *
     * @param <T>    the object type
     * @param object the object to check
     * @return boolean the validated result true or false
     * @see EksDate#isDateTime(CharSequence)
     */
    public static <T> boolean isDateTime(@Nullable final T object) {
        return object != null && EksDate.isDateTime(String.valueOf(object));
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 判断字符串是否指定日期格式
     *
     * <pre>
     * EksCheck.isDateTimeFormat(null, "yyyy-MM-dd")                             = false
     * EksCheck.isDateTimeFormat("", "yyyy-MM-dd")                               = false
     * EksCheck.isDateTimeFormat("2019/10/18", "yyyy/MM/dd")                     = true
     * EksCheck.isDateTimeFormat("2019-10-18", "yyyy-MM-dd")                     = true
     * EksCheck.isDateTimeFormat("20191018", "yyyy-MM-dd")                       = false
     * EksCheck.isDateTimeFormat("2019-10-18 12:12:12", "yyyy-MM-ddTHH:mm:ss")   = false
     * EksCheck.isDateTimeFormat("2019-10-18 12:12:12", "yyyy-MM-dd HH:mm:ss")   = true
     * </pre>
     *
     * @param <T>     the object type
     * @param chars   the object to check
     * @param pattern the datetime format. for example: yyyy-MM-dd HH:mm:ss
     * @return boolean the validated result true or false
     * @see EksDate#isDateTimeFormat(CharSequence, String)
     */
    public static <T extends CharSequence> boolean isDateTimeFormat(@Nullable final T chars, final String pattern) {
        return EksDate.isDateTimeFormat(chars, pattern);
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 判断字符串是否指定日期格式
     *
     * <pre>
     * EksCheck.isDateTimeFormat(null, "yyyy-MM-dd")                             = false
     * EksCheck.isDateTimeFormat("", "yyyy-MM-dd")                               = false
     * EksCheck.isDateTimeFormat("2019/10/18", "yyyy/MM/dd")                     = true
     * EksCheck.isDateTimeFormat("2019-10-18", "yyyy-MM-dd")                     = true
     * EksCheck.isDateTimeFormat("20191018", "yyyy-MM-dd")                       = false
     * EksCheck.isDateTimeFormat("2019-10-18 12:12:12", "yyyy-MM-ddTHH:mm:ss")   = false
     * EksCheck.isDateTimeFormat("2019-10-18 12:12:12", "yyyy-MM-dd HH:mm:ss")   = true
     * </pre>
     *
     * @param <T>     the object type
     * @param object  the object to check
     * @param pattern the datetime format. for example: yyyy-MM-dd HH:mm:ss
     * @return boolean the validated result true or false
     * @see EksDate#isDateTimeFormat(CharSequence, String)
     */
    public static <T> boolean isDateTimeFormat(@Nullable final T object, final String pattern) {
        return object != null && EksDate.isDateTimeFormat(String.valueOf(object), pattern);
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 验证正则表达式是否匹配
     *
     * @param regex The expression to be compiled
     * @param chars The character sequence to be matched
     * @return boolean the validated result true or false
     */
    public static <T extends CharSequence> boolean isMatch(@Nullable String regex, @Nullable T chars) {
        if (regex == null || chars == null) {
            return false;
        }
        try {
            return Pattern.matches(regex, chars);
        } catch (PatternSyntaxException pse) {
            return false;
        }
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 验证正则表达式是否不匹配
     *
     * @param regex The expression to be compiled
     * @param chars The character sequence to be matched
     * @return boolean the validated result true or false
     */
    public static <T extends CharSequence> boolean notMatch(@Nullable String regex, @Nullable T chars) {
        return !isMatch(regex, chars);
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 验证正则表达式是否匹配
     *
     * @param regex  The expression to be compiled
     * @param object The object sequence to be matched
     * @return boolean The validated result true or false
     */
    public static <T> boolean isMatch(@Nullable String regex, @Nullable T object) {
        return object != null && isMatch(regex, String.valueOf(object));
    }

    //-----------------------------------------------------------------------------------------------------------------

    /**
     * * 验证正则表达式是否不匹配
     *
     * @param regex  The expression to be compiled
     * @param object The object sequence to be matched
     * @return boolean The validated result true or false
     */
    public static <T> boolean notMatch(@Nullable String regex, @Nullable T object) {
        return object == null || notMatch(regex, String.valueOf(object));
    }
}
